/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.loja.view.component.composition.factory;

import br.com.loja.model.service.exception.ServiceException;
import br.com.loja.view.component.composition.BooleanToOne;
import br.com.loja.view.component.composition.CalendarToOne;
import br.com.loja.view.component.composition.CommonToOne;
import br.com.loja.view.component.composition.EntityToOne;
import br.com.loja.view.component.factory.ComponentFactory;
import java.awt.Component;

/**
 *
 * @author DavidLuiz
 */
public class CompositionToOneFactory extends ComponentFactory {

    public CompositionToOneFactory(Class<?> classType) {
        super(classType);
    }

    @Override
    public Component getComponent() {

        if (isBoolean()) {
            return new BooleanToOne();
        }
        if (isCalendar()) {
            return new CalendarToOne();
        }
        if (isEntity()) {
            try {
                return new EntityToOne(getClassType());
            } catch (ServiceException ex) {
                //implenentar log
                System.out.println(ex.getMessage());
                ex.printStackTrace();
            }
        }

        return new CommonToOne(getClassType());

    }

}
